package generic;

/**
 *
 * Counted Object类能够记录下它创建了多少个CountedObject实例， 并通过toString()告
 * 诉我们其编号。
 *
 * @author ChangLiang
 * @date 2021/2/1
 */
public class CountedObject {

    private static long counter = 0;
    private final long id = counter++;

    public long id() {
        return id;
    }

    @Override
    public String toString() {
        return "CountedObject " + id;
    }
}
